<div class="form-group">
    <label class="col-lg control-label must">身份等级</label>
    <div class="col-sm-8">
        <select name="levelnum" style="width:100px;" class="form-control tp_is_default valid" id="levelnum">
            {if $item['levelnum'] != 0 || empty($item)}
            {loop $levelnum $num}
            <option value="{$num}" {if $num == $item['levelnum']}selected{/if}>{$num}</option>
            {/loop}
            {else}
            <option value="{$item['levelnum']}" selected>{$item['levelnum']}</option>
            {/if}
        </select>
        <span class="help-block">数字越大等级越高</span>
    </div>
</div>
<div class="form-group">
    <label class="col-lg control-label must">身份名称</label>
    <div class="col-sm-8">
        {ife 'mendian.user' $item}
        <input type="text" class="form-control" name="name" value="{$item['name']}" data-rule-required="true"/>
        {else}
        <div class="form-control-static">{$item['name']}</div>
        {/if}
    </div>
</div>



<div class="form-group-title">身份信息</div>
<!-- 会员 start -->
<div class="form-group">
    <label class="col-lg control-label">是否使用会员等级</label>
    <div class="col-sm-8">
        <label class="radio-inline">
            <input type="radio" name='is_use_member_level' value="1" {if $item['is_use_member_level']==1}checked{/if} onclick="levelshow('member')"/> 是
        </label>
        <label class="radio-inline">
            <input type="radio" name='is_use_member_level' value="0" {if empty($item['is_use_member_level'])}checked{/if} onclick="levelhide('member')"/> 否
        </label>
    </div>
</div>
<div class="form-group" id="member" {if empty($item['is_use_member_level'])}style="display:none;"{/if}>
    <label class="col-lg control-label">有效期会员等级</label>
    <div class="col-sm-2">
        <select name="shop_user_grade_id" class="select2" style="width:150px;">
            <option value="">请选择会员等级</option>
            <option value="" {if $item['shop_user_grade_id'] == '0'}selected{/if}>默认等级</option>
            {loop $user $row}
            <option value="{$row['id']}" {if $item['shop_user_grade_id'] == $row['id']}selected{/if}>{$row['levelname']}{if $row['enabled'] == 0}(未启用){/if}</option>
            {/loop}
        </select>
    </div>

    <label class="col-lg control-label">到期会员等级</label>
    <div class="col-sm-2">
        <select name="end_shop_user_grade_id" class="select2" style="width:150px;">
            <option value="">请选择会员等级</option>
            <option value="" {if $item['end_shop_user_grade_id'] == '0'}selected{/if}>默认等级</option>
            {loop $user $row}
            <option value="{$row['id']}" {if $item['end_shop_user_grade_id'] == $row['id']}selected{/if}>{$row['levelname']}{if $row['enabled'] == 0}(未启用){/if}</option>
            {/loop}
        </select>
    </div>
</div>
<!-- 会员 end -->


<!-- 分销 start -->
<div class="form-group">
    <label class="col-lg control-label">是否使用分销等级</label>
    <div class="col-sm-8">
        <label class="radio-inline">
            <input type="radio" name='is_use_distribution_level' value="1" {if $item['is_use_distribution_level']==1}checked{/if} onclick="levelshow('distribution')"/> 是
        </label>
        <label class="radio-inline">
            <input type="radio" name='is_use_distribution_level' value="0" {if empty($item['is_use_distribution_level'])}checked{/if} onclick="levelhide('distribution')"/> 否
        </label>
    </div>
</div>
<div class="form-group" id="distribution" {if empty($item['is_use_distribution_level'])}style="display:none;"{/if}>
    <label class="col-lg control-label">有效期分销商等级</label>
    <div class="col-sm-2">
        <select name="distribution_grade_id" class="select2" style="width:150px;">
            <option value="">请选择分销商等级</option>
            <option value="" {if $item['distribution_grade_id'] == '0'}selected{/if}>默认等级</option>
            {loop $distribution $row}
            <option value="{$row['id']}" {if $item['distribution_grade_id'] == $row['id']}selected{/if}>{$row['levelname']}</option>
            {/loop}
        </select>
    </div>

    <label class="col-lg control-label">到期分销商等级</label>
    <div class="col-sm-2">
        <select name="end_distribution_grade_id" class="select2" style="width:150px;">
            <option value="">请选择分销商等级</option>
            <option value="-1" {if $item['end_distribution_grade_id']=='-1'}selected{/if}>待审核</option>
            <option value="" {if $item['end_distribution_grade_id'] == '0'}selected{/if}>默认等级</option>
            {loop $distribution $row}
            <option value="{$row['id']}" {if $item['end_distribution_grade_id'] == $row['id']}selected{/if}>{$row['levelname']}</option>
            {/loop}
        </select>
    </div>
</div>
<!-- 分销 end -->


<!-- 门店 start -->
<div class="form-group">
    <label class="col-lg control-label">是否使用门店等级</label>
    <div class="col-sm-8">
        <label class="radio-inline">
            <input type="radio" name='is_use_mendian' value="1" {if $item['is_use_mendian']=='1'}checked{/if}  onclick="levelshow('mendian')"/> 是 
        </label>
        <label class="radio-inline">
            <input type="radio" name='is_use_mendian' value="0" {if empty($item['is_use_mendian'])}checked{/if} onclick="levelhide('mendian')"/> 否
        </label>
    </div>
</div>
<div class="form-group" id="mendian" {if empty($item['is_use_mendian'])}style="display:none;"{/if}>
    <label class="col-lg control-label">有效期门店等级</label>
    <div class="col-sm-2">
        <select name="mendian_level_id" class="select2" style="width:150px;">
            <option value="">请选择门店等级</option>
            {loop $mendian_level $row}
            <option value="{$row['id']}" {if $item['mendian_level_id'] == $row['id']}selected{/if}>{$row['levelname']}{if $row['status'] == 0}(未启用){/if}</option>
            {/loop}
        </select>
    </div>

    <label class="col-lg control-label">到期门店等级</label>
    <div class="col-sm-2">
        <select name="end_mendian_level_id" class="select2" style="width:150px;">
            <option value="">请选择门店等级</option>
            <option value="-1" {if $item['end_mendian_level_id']=='-1'}selected{/if}>待审核</option>
            {loop $mendian_level $row}
            <option value="{$row['id']}" {if $item['end_mendian_level_id'] == $row['id']}selected{/if}>{$row['levelname']}{if $row['status'] == 0}(未启用){/if}</option>
            {/loop}
        </select>
    </div>
</div>
<!-- 门店 end -->


<!-- 多商户 start -->
<div class="form-group">
    <label class="col-lg control-label">是否使用多商户</label>
    <div class="col-sm-8">
        <label class="radio-inline">
            <input type="radio" name='is_use_merch' value="1" {if $item['is_use_merch']==1}checked{/if} onclick="levelshow('merch')"/> 是
        </label>
        <label class="radio-inline">
            <input type="radio" name='is_use_merch' value="0" {if empty($item['is_use_merch'])}checked{/if} onclick="levelhide('merch')"/> 否
        </label>
    </div>
</div>
<div class="form-group" id="merch" {if empty($item['is_use_merch'])}style="display:none;"{/if}>
    <label class="col-lg control-label">有效期多商户等级</label>
    <div class="col-sm-2">
        <select name="merch_id" class="select2" style="width:150px;">
            <option value="">请选择多商户等级</option>
            {loop $merch_level $row}
            <option value="{$row['id']}" {if $item['merch_id'] == $row['id']}selected{/if}>{$row['groupname']}{if $row['status'] == 0}(未启用){/if}</option>
            {/loop}
        </select>
    </div>

    <label class="col-lg control-label">到期多商户等级</label>
    <div class="col-sm-2">
        <select name="end_merch_id" class="select2" style="width:150px;">
            <option value="">请选择多商户等级</option>
            <option value="-1" {if $item['end_merch_id']=='-1'}selected{/if}>待审核</option>
            {loop $merch_level $row}
            <option value="{$row['id']}" {if $item['end_merch_id'] == $row['id']}selected{/if}>{$row['groupname']}{if $row['status'] == 0}(未启用){/if}</option>
            {/loop}
        </select>
    </div>
</div>
<!-- 多商户 end -->


<!-- 区域代理 start -->
<div class="form-group">
    <label class="col-lg control-label">是否使用区域代理</label>
    <div class="col-sm-8">
        <label class="radio-inline">
            <input type="radio" name='is_use_abonus_agent' value="1" {if $item['is_use_abonus_agent']==1}checked{/if} onclick="levelshow('abonus')"/> 是
        </label>
        <label class="radio-inline">
            <input type="radio" name='is_use_abonus_agent' value="0" {if empty($item['is_use_abonus_agent'])}checked{/if} onclick="levelhide('abonus')"/> 否
        </label>
    </div>
</div>
<div class="form-group" id="abonus" {if empty($item['is_use_abonus_agent'])}style="display:none;"{/if}>
    <label class="col-lg control-label">有效期区域代理等级</label>
    <div class="col-sm-2">
        <select name="abonus_agent_id" class="select2" style="width:150px;">
            <option value="">请选择区域代理等级</option>
            <option value="" {if $item['abonus_agent_id']=='0'}selected{/if}>默认等级</option>
            {loop $abonus_level $row}
            <option value="{$row['id']}" {if $item['abonus_agent_id'] == $row['id']}selected{/if}>{$row['levelname']}</option>
            {/loop}
        </select>
    </div>

    <label class="col-lg control-label">到期区域代理等级</label>
    <div class="col-sm-2">
        <select name="end_abonus_agent_id" class="select2" style="width:150px;">
            <option value="">请选择区域代理等级</option>
            <option value="-1" {if $item['end_abonus_agent_id']=='-1'}selected{/if}>待审核</option>
            <option value="" {if $item['end_abonus_agent_id']=='0'}selected{/if}>默认等级</option>
            {loop $abonus_level $row}
            <option value="{$row['id']}" {if $item['end_abonus_agent_id'] == $row['id']}selected{/if}>{$row['levelname']}</option>
            {/loop}
        </select>
    </div>
</div>
<!-- 区域代理 end -->


<!-- 全民股东 start -->
<div class="form-group">
    <label class="col-lg control-label">是否使用全民股东</label>
    <div class="col-sm-8">
        <label class="radio-inline">
            <input type="radio" name='is_use_globonus_partner' value="1" {if $item['is_use_globonus_partner']==1}checked{/if} onclick="levelshow('globonus')"/> 是
        </label>
        <label class="radio-inline">
            <input type="radio" name='is_use_globonus_partner' value="0" {if empty($item['is_use_globonus_partner'])}checked{/if} onclick="levelhide('globonus')"/> 否
        </label>
    </div>
</div>
<div class="form-group" id="globonus" {if empty($item['is_use_globonus_partner'])}style="display:none;"{/if}>
    <label class="col-lg control-label">有效期全民股东等级</label>
    <div class="col-sm-2">
        <select name="globonus_partner_id" class="select2" style="width:150px;">
            <option value="">请选择全民股东等级</option>
            <option value="" {if $item['globonus_partner_id']=='0'}selected{/if}>默认等级</option>
            {loop $globonus_level $row}
            <option value="{$row['id']}" {if $item['globonus_partner_id'] == $row['id']}selected{/if}>{$row['levelname']}</option>
            {/loop}
        </select>
    </div>

    <label class="col-lg control-label">到期全民股东等级</label>
    <div class="col-sm-2">
        <select name="end_globonus_partner_id" class="select2" style="width:150px;">
            <option value="">请选择全民股东等级</option>
            <option value="-1" {if $item['end_globonus_partner_id']=='-1'}selected{/if}>待审核</option>
            <option value="" {if $item['end_globonus_partner_id']=='0'}selected{/if}>默认等级</option>
            {loop $globonus_level $row}
            <option value="{$row['id']}" {if $item['end_globonus_partner_id'] == $row['id']}selected{/if}>{$row['levelname']}</option>
            {/loop}
        </select>
    </div>
</div>
<!-- 全民股东 end -->



<script type="text/javascript">
    function levelshow(obj){
        console.log('show'+obj);
        $("#"+obj).attr('style', 'display:block;');
    }
     function levelhide(obj){
        console.log('hide'+obj);
        $("#"+obj).attr('style', 'display:none;');
    }
</script>


<!-- 购买升级身份商品 start -->
<div class="form-group">
    <label class="col-lg control-label must">购买升级身份商品</label>
    <div class="col-sm-8">
        {ifp 'identity.user.edit'}
              {php echo tpl_selector('buy_goods_id',array('url'=>webUrl('goods/query'), 'items'=>$goods,'buttontext'=>'选择商品','placeholder'=>'请输入商品标题','preview'=>false))}
        {else}
            {if !empty($goods)}
                <a href="{php echo webUrl('goods/edit',array('id'=>$goods['id']))}" target="_blank">{$goods['title']}(ID: {$goods['id']})</a>
            {else}
                未选择商品
            {/if}
        {/if}
    </div>
</div>
<!-- 购买升级身份商品 end -->


<!-- 有效时间 start -->
<div class="form-group">
    <label class="col-lg control-label">有效时间{$item['useful_time']}</label>
    <div class="col-sm-9 col-xs-12">
        <label class="radio-inline">
            <input type="radio" name='useful_time' class="useful_time" value="36500" {if $item['useful_time'] == '36500'}checked{/if} /> 永久(36500天)
        </label>
        {if $item['levelnum'] != 0 || empty($item)}
        <label class="radio-inline">
            <input type="radio" name='useful_time' class="useful_time" value="365" {if $item['useful_time'] == '365'}checked{/if} /> 一年(365天)
        </label>
        <label class="radio-inline">
            <input type="radio" name='useful_time' class="useful_time" value="730" {if $item['useful_time'] == '730'}checked{/if} /> 两年(730天)
        </label>
        <label class="radio-inline">
            <input type="radio" name='useful_time' value="" {if $item['useful_time'] != '36500' && $item['useful_time'] != '365' && $item['useful_time'] != '730'}checked{/if} id="diy_time" /> 
            <span>自定义天数</span> 
            <span><input type="text" name='useful_time1' value="{$item['useful_time']}" id="diy_useful_time" disabled="disabled"  style="width:60px;border: 1px solid #efefef;" /></span> 天
        </label>
        {/if}
    </div>
    <script type="text/javascript">
        if ($('#diy_time').attr('checked')) {
            $('#diy_useful_time').removeAttr('disabled');
        }

        $('.useful_time').click(function(){
            $('#diy_useful_time').attr('disabled', 'disabled');
        });
        $('#diy_time').click(function(){
            $('#diy_useful_time').removeAttr('disabled');
        });
        
    </script>
</div>
<!-- 有效时间 end -->


<div class="form-group-title">状态</div>
<div class="form-group">
    <label class="col-lg control-label">状态</label>
    <div class="col-sm-9 col-xs-12">
        {ife 'mendian.user' $item}
        <label class="radio-inline">
            <input type="radio" name='status' value="1" {if $item['status']==1}checked{/if} /> 启用
        </label>
        <label class="radio-inline">
            <input type="radio" name='status' value="0" {if empty($item['status'])}checked{/if} /> 禁用
        </label>
        {else}
        <div class='form-control-static'>{if empty($item['status'])}否{else}是{/if}</div>
        {/if}
    </div>
</div>

<!--青岛易联互动网络科技有限公司-->